<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <button v-for='title in  titles' :key="title" @click="currentCom = title">
      {{title}}
    </button>
    <component :is="currentCom"></component>
  </div> 
</body>
<script src="../lib/vue.js"></script>
<script>
  var ComA = {
    template: '<p>这是组件A</p>'
  }
  var ComB = {
    template: '<p>这是组件B</p>'
  }
  var ComC = {
    template: '<p>这是组件C</p>'
  }
  new Vue({
    el: '#app',
    data: {
      titles: ['ComA', 'ComB', 'ComC'],
      currentCom: 'ComA'
    },
    components: {
      ComA, ComB, ComC
    }
  })
</script>

</html>